<style type="text/css" media="all">
    /*.layui-table td{ text-align:center!important; line-height:65px;}
    .layui-table tr{height:65px;line-height:65px;}*/
</style>
<div class="layui-container">  
    <div class="layui-row">
        <div class="layui-col-md6">
            <form  class="layui-form">
            <table class="layui-table">
                <tbody>
                    <tr>
                        <td width='100'>显示图标</td>
                        <td>
                            <img id="img_logo" src="{$configs['icon']}" alt="图标" style="width:64px;height:64px;border:1px solid #ccc;" /> <span  style="font-size:12px;">点击图片上传图标</span>
                            <input type="hidden" name="icon" id='alipay_icon' value="{$configs['icon']|default=''}" />
                        </td>
                    </tr>
                    <tr>
                        <td>支付宝网关</td>
                        <td>
                            <input type="text" name="alipay_getway" lay-verify="title" autocomplete="off" placeholder="请输入支付宝网关" value="{$configs['alipay_getway']|default=''}" class="layui-input">
                        </td>
                    </tr>
                    <tr>
                        <td>APPID</td>
                        <td>
                            <input type="text" name="appid" lay-verify="title" autocomplete="off" placeholder="请输入APPID" value="{$configs['appid']|default=''}" class="layui-input">
                        </td>
                    </tr>
                    <tr>
                        <td>应用私钥</td>
                        <td>
                            <textarea name="app_private_key" style="width:100%;" placeholder="请输入应用私钥" rows="8" cols="40">{$configs['app_private_key']|default=''}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>支付宝公钥</td>
                        <td>
                            <textarea name="alipay_public_key"  style="width:100%;" placeholder="请输入支付宝公钥" rows="8" cols="40">{$configs['alipay_public_key']|default=''}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="text-align:center;">
                            <button type="button" class="layui-btn layui-btn-sm " lay-submit lay-filter="setconfig">保存配置</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>
        </div>
    </div>
</div>
<!-- 自动加载js -->
<div style="display:none;" class="__is_autoload_js__">
    ;(function(){
        var upload = layui.upload; 
        var form = layui.form;
        
        //执行实例
        var uploadInst = upload.render({
            elem: '#img_logo' //绑定元素
            ,url: '{:cmf_plugin_url("Pay://admin_index/payIcon")}' //上传接口
            ,done: function(res){
            //上传完毕回调
                layer.msg( res.message , { time:1000 , icon:(res.code ==200 )?1:5 } , function(){
                    if ( res.code == 200 ){
                        $( '#img_logo' ).attr( 'src' , res.data );
                        $( '#alipay_icon' ).val( res.data );
                    }
                } );
            }
            ,error: function(){
            //请求异常回调
            }
        });
        
        //监听提交
        form.on('submit(setconfig)', function(data){
            $.ajax({
                url:'{:cmf_plugin_url("Pay://alipay/setConfig")}',
                data:{config:data.field},
                method:'post',
                success:function(res){
                    layer.msg( res.message , { time:1000 , icon:(res.code ==200 )?1:5 } , function(){
                        if ( res.code == 200 ){
                            window.location.reload();
                        }
                    } );
                }
            });
            return false;
        });
    })();
</div>
<!-- 自动加载js -->
